<template>
  <div>
    <el-row style="text-align: right">
      <el-button type="primary" style="margin-right: 50px" @click="getAccountBalance">刷新</el-button>
    </el-row>
    <el-row>
      <el-table v-loading="loading"
                :data="accountBalance"
                :row-class-name="totalRawClass"
                :span-method="platformUnion"
                border
                style="width: 100%; margin-top: 20px;overflow: auto;">
        <el-table-column
          prop="platformName"
          label="交易所">
        </el-table-column>
        <el-table-column
          label="当前USDT">
          <template slot-scope="scope">
            {{ scope.row.totalUsdt.toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column
          :label="platform=='tcex'?'当前TC':platform=='wbfex'?'当前Water':'当前MDU'">
          <template slot-scope="scope">
            {{ scope.row.totalMdu.toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column
          label="可用Usdt">
          <template slot-scope="scope">
            {{ scope.row.availableUsdt.toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column
          :label="platform=='tcex'?'可用TC':platform=='wbfex'?'可用Water':'可用MDU'">
          <template slot-scope="scope">
            {{ scope.row.availableMdu.toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="info"
          label="帐号">
        </el-table-column>
        <el-table-column
          label="盈亏额">
          <template slot-scope="scope">
            {{ (scope.row.totalUsdt - scope.row.initUsdt).toFixed(2) }}
          </template>
        </el-table-column>
      </el-table>
    </el-row>
  </div>
</template>
<script>
import {
  getCurrentBalance
} from "@/api/platform/running";


export default {
  components: {},
  props: {
    platform: null,
    runningId: null,
  },
  data() {
    return {
      loading: false,
      accountBalance: []
    }
  },
  computed: {},
  watch: {},
  created() {
  },

  mounted() {
    this.getAccountBalance();
  },
  methods: {
    getAccountBalance() {
      this.loading = true
      getCurrentBalance(this.runningId,{platform: this.platform}).then(res => {
        this.loading = false
        this.accountBalance = res.data;
      }).catch(err => {
          this.loading = false
          console.log(err)
        }
      )
    },
    totalRawClass({row, rowIndex}) {
      console.log(row)
      if (rowIndex % 3 === 2) {
        return 'totalrow';
      }
      return '';
    },
    platformUnion({row, column, rowIndex, columnIndex}) {
      console.log(column)
      console.log(rowIndex)
      if (columnIndex === 0) {
        if (rowIndex % 3 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else if (row.platformName === '瓦特合计' || row.platformName === '抹茶合计' || row.platformName === '虎符合计'|| row.platformName === 'DBank合计') {
          return {
            rowspan: 1,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    }
  }
}

</script>
<style>
</style>
